package com.tang.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tang.constants.SystemConstants;
import com.tang.sys.ResponseResult;
import com.tang.sys.entity.Menu;
import com.tang.sys.entity.Role;
import com.tang.sys.entity.RoleMenu;
import com.tang.sys.mapper.MenuMapper;
import com.tang.sys.service.IMenuService;
import com.tang.sys.service.IRoleMenuService;
import com.tang.sys.service.IRoleService;
import com.tang.sys.vo.AdminRoleUpdateMenuVo;
import com.tang.sys.vo.LinkVo;
import com.tang.sys.vo.MenuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.swing.tree.TreeNode;
import java.util.List;

@RestController
@RequestMapping("/system/menu")
public class AdminMenuController {

    @Autowired
    private IMenuService iMenuService;
    @Autowired
    private IRoleMenuService iRoleMenuService;
    @Resource
    private MenuMapper menuMapper;

    @Autowired
    private IRoleService iRoleService;

    //获取菜单
    @GetMapping("/list")
    public ResponseResult AllListMenu(){
        List<MenuVo> list = iMenuService.AllListMenu();
        return ResponseResult.okResult(list);
    }
    //新增
    @PostMapping
    public ResponseResult<MenuVo> addMenuList(@RequestBody MenuVo menuVo) {

        return iMenuService.addMenuList(menuVo);
    }
    //修改
    @GetMapping("{id}")
    public ResponseResult getMenuList(@PathVariable("id") String id){

        return iMenuService.getMenuList(id);
    }
    @PutMapping
    public ResponseResult<MenuVo> updateMenu(@RequestBody MenuVo menuVo){

        return iMenuService.updateMenu(menuVo);
    }
    //删除
    @DeleteMapping("{id}")
    public ResponseResult deleteMenu(@PathVariable("id") Long id){

        return iMenuService.deleteMenu(id);
    }

    //菜单显示
    @GetMapping("/treeselect")
    public ResponseResult getRoleMenuList(){

        return iMenuService.getRoleMenuList();
    }

    //修改角色菜单显示
    @GetMapping("/roleMenuTreeselect/{id}")
    public ResponseResult getRoleMenuUpdate(@PathVariable("id") Long id){

        return iMenuService.getRoleMenuUpdate(id);
    }
}
